class CapitulosController < ApplicationController
  # GET /capitulos
  # GET /capitulos.xml
  def index
    @capitulos = Capitulo.all

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @capitulos }
    end
  end

  # GET /capitulos/1
  # GET /capitulos/1.xml
  def show
    @capitulo = Capitulo.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @capitulo }
    end
  end

  # GET /capitulos/new
  # GET /capitulos/new.xml
  def new
    @capitulo = Capitulo.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @capitulo }
    end
  end

  # GET /capitulos/1/edit
  def edit
    @capitulo = Capitulo.find(params[:id])
  end

  # POST /capitulos
  # POST /capitulos.xml
  def create
    @capitulo = Capitulo.new(params[:capitulo])

    respond_to do |format|
      if @capitulo.save
        flash[:notice] = 'Capitulo was successfully created.'
        format.html { redirect_to(@capitulo) }
        format.xml  { render :xml => @capitulo, :status => :created, :location => @capitulo }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @capitulo.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /capitulos/1
  # PUT /capitulos/1.xml
  def update
    @capitulo = Capitulo.find(params[:id])

    respond_to do |format|
      if @capitulo.update_attributes(params[:capitulo])
        flash[:notice] = 'Capitulo was successfully updated.'
        format.html { redirect_to(@capitulo) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @capitulo.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /capitulos/1
  # DELETE /capitulos/1.xml
  def destroy
    @capitulo = Capitulo.find(params[:id])
    @capitulo.destroy

    respond_to do |format|
      format.html { redirect_to(capitulos_url) }
      format.xml  { head :ok }
    end
  end
end
